const Router = require('koa-router')
const UserController = require('../controllers/user.controller')
const jwt = require('../middlewares/jwt.middleware')
const isRole = require('../middlewares/role.middleware')

const router = new Router()
const userController = new UserController()
router.prefix('/api/users')

router.get('/', jwt, userController.findAll)

router.get('/:id', jwt, userController.findOne)

router.patch('/:id', jwt, isRole(['admin']), userController.updateOne)

router.delete('/:id', jwt, isRole(['admin']), userController.deleteOne)

module.exports = router